// #autoload
function FDCHIP()
{
     exec("scripts/autoexec/FeatherDev/FDCHIP.cs");
}
   
   function GetTipMessage() {
   %l = getRandom(1,5);
   switch(%l) {
      case 1:
      %tip = "FeatherDev Does not only help with clans but also helps others.";
      case 2:
      %tip = "FeatherDev Has No ENEMIES because we are allies with all clans";
      case 3:
      %tip = "If your clan wants to battle an enemy clan then goto the arena on fridays and battle it out";
      case 4:
      %tip = "If you join FeatherDev you can get an AutoResponse Bot";
	  case 5:
      %tip = "There is the new The-construct logo and the new FeatherDev Switches";
	 }
      return %tip;
   }
   
   function GetGreeting() {
   %r = getRandom(1,6);
   switch(%r) {
      case 1:
      %Greet = "Hello,";
      case 2:
      %Greet = "Hi,";
      case 3:
      %Greet = "What's up,";
      case 4:
      %Greet = "Hola,";
	  case 5:
      %Greet = "Yo,";
	  case 6:
	  %Greet = "Hey,";
	 }
      return %Greet;
   }
   
 package MazoChat
{ 
	function clientCmdChatMessage(%sender, %voice, %pitch,%msgString, %a1, %a2, %a3, %a4, %a5, %a6, %a7, %a8, %a9, %a10)
	{


		%message = strLwr(%a2);
    %M = detag(%a1);
		if(!$T)
		{	
		 switch$(%a2) //Greeting to the player
 {
  case "Hello "@$User or "Hi "@$User or "Hola "@$User or "Yo "@$User or "what's up "@$User or "Hey "@$User or "whats up "@$User or "what is up "@$User:
	%Greet = GetGreeting();
	commandtoserver('messagesent', $Bot @ "\c4: " @ %Greet @ " " @ %M);
  case "How long has your comp been on "@$User or "how long hae you been on "@$User or "logged time on "@$User :
	$CS = mfloor(getrealtime()/1000);
	$CM = mfloor(getrealtime()/60000);
	$CH = mfloor(getrealtime()/3600000);
	$CD = mfloor(getrealtime()/86400000);
	if( $CS > 60) {
	$CS = $CS - ($CM * 60);
	}
	if( $CM > 60) {
	$CM = $CM - ($CH * 60);
	}
	if( $CH > 24) {
	$CH = $CH - ($CD * 24);
	}
    schedule(1500, 0, commandtoserver, 'messagesent', $Bot @ "\c4: This comp has been on: "@ $CD @" Day(s), "@ $CH @" Hour(s), "@ $CM @" Minute(s), and "@ $CS @" Second(s), since last shutdown.");
  case $AR@ "what is the time" or $AR@ "what time is it" or $AR@ "Que hora es":
    schedule(1500, 0, commandtoserver, 'messagesent', $Bot @ "\c4: The time is: "@formatTimeString("h:nn A")@"");
  case "i wonder what the time is" or "i wonder what time it is":
    schedule(1500, 0, commandtoserver, 'messagesent', $Bot @ "\c4: I am glad you asked, The time as of right now is: "@formatTimeString("h:nn A")@"");
  case $AR@ "what day is it" or $AR@ "what day is today" or $AR@ "what is todays date" or $AR@ "what is the date" or $AR@ "Que dia es":
    schedule(1500, 0, commandtoserver, 'messagesent', $Bot @ "\c4: The day is: "@formatTimeString("DD, MM dd")@"");
  case $AR@ "what is the date and time" or $AR@ "what time and day is it":
    schedule(1500, 0, commandtoserver, 'messagesent', $Bot @ "\c4: The time and day is: "@formatTimeString("h:nn A. DD, MM dd")@"");
  case $AR@ "Version":
	commandtoserver('messagesent', $Bot @ "\c4: This is Currently \c3Version " @ $Version);				
  case $AR@ "History":
	commandtoserver('messagesent', $Bot @ "\c4: Version History: \c3" @ $Ver_His);
  case $AR@ "Help":  
	commandtoserver('messagesent', $Bot @ "\c4: Commands: Version, History, get time");
		 }
			   if($TechScript::AutoVote){
			  switch$(getWord(%message, 0)) {
               case $User:
				if(%a2 != -1){
				commandtoserver('messagesent', $Bot @ "\c4: Sorry the owner is Currently AFK.");
               }
				}
			 
               }
			   if(!$TechScript::AutoVote){
			  switch$(getWord(%message, 0)) {
               case $User:
				$Player = GetMutePlayer();
			   if(%M $= $Player){
			   Commandtoserver('messagesent',$Bot @"\c4: Sorry "@ %M @", You are on the Mute list");
			   }
			   else if(%M !$= $Player){
				commandtoserver('messagesent', $Bot @ "\c4: The Owner is Not AFK.");
				}
				}
				}
		}
	%NewMsg = TextCatchIncoming(%sender, %voice, %pitch, %msgString, %a1, %a2, %a3, %a4, %a5, %a6, %a7, %a8, %a9, %a10);
	if(%NewMsg !$= "" || %a1 $= "")
		Parent::clientCmdChatMessage(%sender, %voice, %pitch, %msgString, %a1, %NewMsg, %a3, %a4, %a5, %a6, %a7, %a8, %a9, %a10);

	}
	function MessageHud_Edit::eval(%this)
	{
		%text = trim(%this.getValue());
		MessageHud.close();

		if(%text !$= "")
		{

		//custom commands... (if one is found then don't send the message to others)
		%TC = TextCatch(%text);
		if(%TC==1)
			return;
		if(%TC!$="")
			%text = %TC;

		if(MessageHud.isTeamMsg)
			commandToServer('TeamMessageSent', %text);
		else
			commandToServer('MessageSent', %text);
		}

		Parent::eval(%this);
	}
};
activatePackage(MazoChat);

function TextCatch(%text){
	if (getSubStr(%text, 0, 1) $= "|")
	{

	%cmd=getWord(%text,0);
	%cmd=stripChars(%cmd,"|");
	%args=getwords(%text,1);
        call("FD"@%cmd,%args);

	return 1;
	}

	if(getSubStr(%text, 0, 1) $= "]")
	{
		%text = SimpleEncrypt(%text);
		return %text;
	}
}
function TextCatchIncoming(%sender, %voice, %pitch, %msgString, %a1, %a2, %a3, %a4, %a5, %a6, %a7, %a8, %a9, %a10){
	//get msg sender info
	%Send = getWords(%a1, 1, getWordCount(%a1));
	%color = "\c4";
	
	if (%a1 $= "")
		return "";
	//decrypt the message if need be
	if(getSubStr(%a2, 0, 1) $= "~")
		%decrypted = SimpleDecrypt(%a2);

	//trim up any spaces
	trim(%a2);

	//Display my brand new message
	if(%decrypted !$= ""){
		clientCmdServerMessage(0, "\c0" @ %Send @ ": " @ %a2);
		clientCmdServerMessage(0, %color @ %Send @ ": " @ %decrypted);
	}
	else{
		clientCmdServerMessage(0, %color @ %Send @ ": " @ %a2);
	}
	
	
}


	function FDAFK(%a2) {
	if(%a2 $= ""){
	%a2 = "\c2none";
	}
		commandtoserver('messagesent',"\c2Has gone AFK \c3(Reason: \c2"@ %a2 @"\c3)");
		$Time = getrealtime();
		$TechScript::AutoVote = 1;
		}
	function FDback() {
	$Now = getrealtime()-$Time;
	$BS = mfloor($Now/1000);
	$BM = mfloor($Now/60000);
	$BH = mfloor($Now/3600000);
	if( $BH < 0) {
	$BH = 0;
	}
	if( $BM < 0) {
	$BM = 0;
	}
	if( $BS > 60) {
	$BS = $BS - ($BM * 60);
	}
	if( $BM > 60) {
	$BM = $BM - ($BH * 60);
	}

		commandtoserver('messagesent',"\c2Has Been AFK for, \c3"@ $BH @" Hour(s), "@ $BM @" Minute(s), and "@ $BS @" Second(s).");
	$Now = 0;
	$Time = 0;
	$TechScript::AutoVote = 0;
			}
	
function FDBotT()
{
	 if(!$T)
     {
     $T = 1;
     addmessagehudline("\c2AR "@ $Bot @" \c5Disabled.");
	 commandtoserver('messagesent',"\c5[AR]\c4: "@ $Bot @" Is: \c3Disabled");
     }
     else
     {
     $T = 0;
     addmessagehudline("\c2AR "@ $Bot @" \c5Enabled.");
	 commandtoserver('messagesent',"\c5[AR]\c4: "@ $Bot @" Is: \c3Enabled");
     }
}

function FDRWP()
{
%N = Noun();
%VN = Verb();
	 commandtoserver('messagesent',"\c5[RWP]\c4: "@ %N @" "@ %VN );

}

function AutovoteToggle(%val)
{
	if(%val){
		schedule(3000, 0, "clientCmdBottomPrint","Auto Vote " @ (($TechScript::AutoVote = !$TechScript::AutoVote) ? "<color:2DC800>EnAbLeD" : "<color:F70000>DiSaBlEd"), 2, 1);
	if($TechScript::AutoVote){
	        clientCmdBottomPrint("<just:center>Please Wait as Auto Vote is <color:2DC800>Starting Up.", 2, 1);
	        schedule(500, 0, "clientCmdBottomPrint","<just:center><color:2DC800>Now Starting", 2, 1);
	        schedule(1000, 0, "clientCmdBottomPrint","<just:center>Now Enabling[<color:ffffff>- - - - - -]", 2, 1);
	        schedule(1500, 0, "clientCmdBottomPrint","<just:center>Now Enabling[<color:2DC800>| <color:ffffff>- - -]", 2, 1);
	        schedule(2000, 0, "clientCmdBottomPrint","<just:center>Now Enabling[<color:2DC800>| | <color:ffffff>- -]", 2, 1);
	        schedule(2500, 0, "clientCmdBottomPrint","<just:center>Now Enabling[<color:2DC800>| | | <color:ffffff>-]", 2, 1);
			schedule(2500, 0, "commandtoserver",'messagesent', $Bot @ "\c4: " @ $User @ " is AFK");
}
	if(!$TechScript::AutoVote){
		clientCmdBottomPrint("<just:center>Please Wait as Auto Vote is <color:F70000>Shutting Down.", 2, 1);
	        schedule(500, 0, "clientCmdBottomPrint","<just:center><color:F70000>Now Ending", 2, 1);
	        schedule(1000, 0, "clientCmdBottomPrint","<just:center>Now Disabling [<color:ffffff>- - - - - -]", 2, 1);
	        schedule(1500, 0, "clientCmdBottomPrint","<just:center>Now Disabling [<color:F70000>| <color:ffffff>- - -]", 2, 1);
	        schedule(2000, 0, "clientCmdBottomPrint","<just:center>Now Disabling [<color:F70000>| | <color:ffffff>- -]", 2, 1);
	        schedule(2500, 0, "clientCmdBottomPrint","<just:center>Now Disabling [<color:F70000>| | | <color:ffffff>-]", 2, 1);
			schedule(2500, 0, "commandtoserver",'messagesent', $Bot @ "\c4: " @ $User @ " is Not AFK");
}
}
}

error("FDCHIP: AFK/Auto vote loaded");

$ROT::Letters["Letter"] = 53;
$ROT::Letters["Letter",1] = "a";
$ROT::Letters["Letter",2] = "b";
$ROT::Letters["Letter",3] = "c";
$ROT::Letters["Letter",4] = "d";
$ROT::Letters["Letter",5] = "e";
$ROT::Letters["Letter",6] = "f";
$ROT::Letters["Letter",7] = "g";
$ROT::Letters["Letter",8] = "h";
$ROT::Letters["Letter",9] = "i";
$ROT::Letters["Letter",10] = "j";
$ROT::Letters["Letter",11] = "k";
$ROT::Letters["Letter",12] = "l";
$ROT::Letters["Letter",13] = "m";
$ROT::Letters["Letter",14] = "n";
$ROT::Letters["Letter",15] = "o";
$ROT::Letters["Letter",16] = "p";
$ROT::Letters["Letter",17] = "q";
$ROT::Letters["Letter",18] = "r";
$ROT::Letters["Letter",19] = "s";
$ROT::Letters["Letter",20] = "t";
$ROT::Letters["Letter",21] = "u";
$ROT::Letters["Letter",22] = "v";
$ROT::Letters["Letter",23] = "w";
$ROT::Letters["Letter",24] = "x";
$ROT::Letters["Letter",25] = "y";
$ROT::Letters["Letter",26] = "z";
$ROT::Letters["Letter",27] = "A";
$ROT::Letters["Letter",28] = "B";
$ROT::Letters["Letter",29] = "C";
$ROT::Letters["Letter",30] = "D";
$ROT::Letters["Letter",31] = "E";
$ROT::Letters["Letter",32] = "F";
$ROT::Letters["Letter",33] = "G";
$ROT::Letters["Letter",34] = "H";
$ROT::Letters["Letter",35] = "I";
$ROT::Letters["Letter",36] = "J";
$ROT::Letters["Letter",37] = "K";
$ROT::Letters["Letter",38] = "L";
$ROT::Letters["Letter",39] = "M";
$ROT::Letters["Letter",40] = "N";
$ROT::Letters["Letter",41] = "O";
$ROT::Letters["Letter",42] = "P";
$ROT::Letters["Letter",43] = "Q";
$ROT::Letters["Letter",44] = "R";
$ROT::Letters["Letter",45] = "S";
$ROT::Letters["Letter",46] = "T";
$ROT::Letters["Letter",47] = "U";
$ROT::Letters["Letter",48] = "V";
$ROT::Letters["Letter",49] = "W";
$ROT::Letters["Letter",50] = "X";
$ROT::Letters["Letter",51] = "Y";
$ROT::Letters["Letter",52] = "Z";
$ROT::Letters["Letter",53] = "";

$ROT::Letters["Letter2"] = 53;
$ROT::Letters["Letter2",1] = "Ø";
$ROT::Letters["Letter2",2] = "Ô";
$ROT::Letters["Letter2",3] = "œ";
$ROT::Letters["Letter2",4] = "Ý";
$ROT::Letters["Letter2",5] = "ä";
$ROT::Letters["Letter2",6] = "Ž";
$ROT::Letters["Letter2",7] = "ª";
$ROT::Letters["Letter2",8] = "ß";
$ROT::Letters["Letter2",9] = "[";
$ROT::Letters["Letter2",10] = "þ";
$ROT::Letters["Letter2",11] = "@";
$ROT::Letters["Letter2",12] = "™";
$ROT::Letters["Letter2",13] = "ë";
$ROT::Letters["Letter2",14] = "¶";
$ROT::Letters["Letter2",15] = "ñ";
$ROT::Letters["Letter2",16] = "«";
$ROT::Letters["Letter2",17] = "›";
$ROT::Letters["Letter2",18] = "Š";
$ROT::Letters["Letter2",19] = "¥";
$ROT::Letters["Letter2",20] = "©";
$ROT::Letters["Letter2",21] = "ƒ";
$ROT::Letters["Letter2",22] = "×";
$ROT::Letters["Letter2",23] = "…";
$ROT::Letters["Letter2",24] = "—";
$ROT::Letters["Letter2",25] = "„";
$ROT::Letters["Letter2",26] = "é";
$ROT::Letters["Letter2",27] = "è";
$ROT::Letters["Letter2",28] = "Æ";
$ROT::Letters["Letter2",29] = "÷";
$ROT::Letters["Letter2",30] = "Ç";
$ROT::Letters["Letter2",31] = "€";
$ROT::Letters["Letter2",32] = "¿";
$ROT::Letters["Letter2",33] = "¸";
$ROT::Letters["Letter2",34] = "Å";
$ROT::Letters["Letter2",35] = "¤";
$ROT::Letters["Letter2",36] = "Ñ";
$ROT::Letters["Letter2",37] = "ž";
$ROT::Letters["Letter2",38] = "®";
$ROT::Letters["Letter2",39] = "±";
$ROT::Letters["Letter2",40] = "§";
$ROT::Letters["Letter2",41] = "†";
$ROT::Letters["Letter2",42] = "Ð";
$ROT::Letters["Letter2",43] = "Û";
$ROT::Letters["Letter2",44] = "(";
$ROT::Letters["Letter2",45] = "¾";
$ROT::Letters["Letter2",46] = "‡";
$ROT::Letters["Letter2",47] = "¬";
$ROT::Letters["Letter2",48] = "ô";
$ROT::Letters["Letter2",49] = "‰";
$ROT::Letters["Letter2",50] = "*";
$ROT::Letters["Letter2",51] = "$";
$ROT::Letters["Letter2",52] = "Â";
$ROT::Letters["Letter2",53] = "_";

function SimpleEncrypt(%args){
	%Key = getRandom(1,25);
	//%Key = 13;

	%count = strLen(%args);
	for(%i=1;%i<%count;%i++){
		%NewLetter = "";
		%CurLetter = getSubStr(%args, %i, 1);

		for(%is=1;%is<54;%is++){
			if($ROT::Letters["Letter",%is] $= %CurLetter){
				%NewLetter = %is + %Key;
				%is = 54;
			}
		}
		
		if(%NewLetter !$= ""){
			if(%NewLetter > 53)
				%NewLetter = %NewLetter*2*2/9-3+5;

			%NewMsg = %NewMsg @ $ROT::Letters["Letter2",%NewLetter];
		}
		else{
			%NewMsg = %NewMsg @ %CurLetter;
		} 
	}
	
	%key = $ROT::Letters["Letter2",%Key];

	%NewMsg = "~" SPC %key SPC %NewMsg;
	return %NewMsg;
}

function SimpleDecrypt(%args){
	//extract key
	%WordKey = getword(%args,1);
	for(%i=1;%i<54;%i++){
		if($ROT::Letters["Letter2",%i] $= %WordKey){
			%Key = %i;
			%i = 54;
		}
	}

	//%Key = 13;

	%count = strLen(%args);
	for(%i=1;%i<%count;%i++){
		%NewLetter = "";
		%CurLetter = getSubStr(%args, %i, 1);

		for(%is=1;%is<54;%is++){
			if($ROT::Letters["Letter2",%is] $= %CurLetter){
				%NewLetter = %is - %Key;
				%is = 54;
			}
		}
		
		if(%NewLetter !$= ""){
			if(%NewLetter < 1)
				%NewLetter = %NewLetter/2/2*3*3+3-5;

			%NewMsg = %NewMsg @ $ROT::Letters["Letter",%NewLetter];
		}
		else{
			%NewMsg = %NewMsg @ %CurLetter;
		} 
	}
	return %NewMsg;
}
#EOF
